//
//  NetErrorView.m
//  JadeShop
//
//  Created by mac on 2019/5/30.
//  Copyright © 2019年 SZJ.test. All rights reserved.
//

#import "NetErrorView.h"
#import "NetWorkTool.h"

@implementation NetErrorView
{
    __weak IBOutlet UIWebView *_webView;
    
    NSString * _url;
    NSDictionary *_params;
    __weak IBOutlet UILabel *_url_l;
    __weak IBOutlet UILabel *_params_l;
}


+ (void)shareWithError:(NSError *)error withUrl:(NSString *)url withParams:(NSDictionary *)params{
    NetErrorView *view = [[NSBundle mainBundle] loadNibNamed:@"NetErrorView" owner:nil options:nil].firstObject;
    NSData *responseData = error.userInfo[@"com.alamofire.serialization.response.error.data"];
    NSString *result = [[NSString alloc] initWithData:responseData  encoding:NSUTF8StringEncoding];
    view.frame = [UIScreen mainScreen].bounds;
    view->_url = url;
    view->_params = params;
    view->_url_l.text = [NSString stringWithFormat:@"报错地址:%@",url];
    view->_params_l.text = [NSString stringWithFormat:@"参数:%@",params.jsonStringEncoded];
    [[UIApplication sharedApplication].keyWindow addSubview:view];
    [view->_webView loadHTMLString:result baseURL:nil];
}




- (IBAction)close:(id)sender {
    [self removeFromSuperview];
}

- (IBAction)refresh:(id)sender {
    
}

@end
